﻿@using Utils
@model Invoicing.Model.Orders.BookOrderModel

<div class="k-block" style="line-height: 35px; margin-bottom: 5px; padding: 0px 5px">
    <b>单据号：</b>@Model.OrderNo
    <b>日期：</b>@(string.Format("{0:yyyy年M月d日}", Model.NoteDate))
    <b>客户：</b>@Model.Customer.ComplexName
</div>

<table id="grid">
    <colgroup>
        <col style="width: 150px" />
        <col style="width: 120px" />
        <col style="width: 80px" />
        <col style="width: 80px" />
        <col />
    </colgroup>
    <thead>
        <tr>
            <th data-field="product"><b>产品型号</b></th>
            <th data-field="martial"><b>材料</b></th>
            <th data-field="process"><b>加工</b></th>
            <th data-field="size"><b>规格</b></th>
            <th data-field="quantity"><b>数量(只)</b></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var o in Model.Items)
        {
            <tr>
                <td>@o.Product.Module</td>
                <td>@o.Material.MaterialName</td>
                <td>@o.Process.ProcessName</td>
                <td>@o.Size</td>
                <td>@o.Quantity.ToString().RemoveLastZero()</td>
            </tr>    
        }
    </tbody>
</table>

<div class="k-block" style="padding: 5px; margin-top: 5px; text-align: center;">
    <a class="k-button" href="/Orders/BookOrder/NewOrder/@Model.Method?orderNo=@Model.OrderNo"><span class="k-icon k-i-calendar "></span><span>修改单据</span></a>
    &nbsp;&nbsp;
    <a class="k-button" href="/Orders/BookOrder/Print/@Model.OrderNo" target="_blank"><span class="k-icon k-i-calendar "></span><span>打印单据</span></a>
    &nbsp;&nbsp;
    <button class="k-button" onclick="CancelGeneralEdit();"><span class="k-icon k-i-cancel"></span><span>&nbsp;关&nbsp;闭</span></button>
     &nbsp;&nbsp;
    <button class="k-button" onclick="CancelOrder('@Model.OrderNo');"><span class="k-icon k-i-close"></span><span>删除单据</span></button>
</div>

<script class="init">
    $(function () {
        $("#grid").kendoGrid({
            dataBound: function (e) {
                //让表头居中
                $("th.k-header").attr("style", "text-align:center; font-weight:bold;");
            }
        });
    });

    function CancelOrder(orderNo) {
        Whale.Remote.Operation({
            url: "/Orders/BookOrder/CancelOrder",
            parameters: {orderNo:orderNo},
            success: function (result) {
                CancelGeneralEdit();
                //wndGeneralInformation.content("单据删除成功，请刷新列表。").open();
                if ($("#grid_orders").length > 0)
                    $("#grid_orders").data("kendoGrid").dataSource.read();
            },
            error: function (msg) {
                wndGeneralInformation.content(msg).open();
            }
        });
    }
</script>

